import { LoginForm, LoginResponse } from "@model/api";

export default {
	login: (params: LoginForm) => {
		return new Promise<ReqRes.ResponseResult<LoginResponse>>((resolve, reject) => {
			const { username, password } = params;
			setTimeout(() => {
				if (username && password && username === "admin" && password === "123456") {
					resolve({
						code: 200,
						data: "a3nbk-da133-asn89-901an",
						info: "登陆成功！",
					});
				} else {
					reject({
						code: 201,
						data: null,
						info: "登陆失败！",
					});
				}
			}, 1500);
		});
	},
	loginOut: () => {
		return new Promise<ReqRes.ResponseResult>(resolve => {
			setTimeout(() => {
				resolve({
					code: 200,
					data: "",
					info: "退出成功！",
				});
			}, 1500);
		});
	},
};
